package com.ase.singleton.solution;

/**
 * @author gyhstart
 * @create 2021/3/6 - 22:46
 **/
public class Solution {
    public static void main(String[] args) {
        System.out.println("Fibonacci(2) = " + Fibonacci(3));
    }

    public static int Fibonacci(int n) {
        int[] res = {1, 1};
        if(n < 2) {
            return res[n];
        }
        int first = 1;
        int second = 1;
        int fibn = 0;
        for(int i = 2; i <= n; i++) {
            fibn = first + second;
            first = second;
            second = fibn;
        }
        return fibn;
    }
}
